package com.heima.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.mapper.AssignmentMapper;
import com.heima.pojos.Assignment;
import com.heima.pojos.User;
import com.heima.pojos.UserStudentAssignment;
import com.heima.service.AssignmentService;
import com.heima.utils.UserThreadLocal;
import com.heima.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AssignmentServiceImpl extends ServiceImpl<AssignmentMapper, Assignment> implements AssignmentService {

    @Autowired
    private AssignmentMapper assignmentMapper;

    /**
     * 发布作业
     *
     * @param assignment
     * @return
     */
    @Override
    public R addWork(Assignment assignment) {
        if (assignment == null) return R.error("错误");

        assignment.setUserId(UserThreadLocal.get().getId());

        assignmentMapper.insert(assignment);
        return R.OK("ok");
    }


}
